/**
 * Created by ZT on 2018/11/1 0001.
 */
import axios from 'axios'
import Vue from 'vue'

(function (window) {
     const  service = axios.create({
         baseURL:'http://127.0.0.1:8084',
         timeout:3000,
         responseType:'json'
     });
    /*请求拦截*/
    service.interceptors.request.use(function (config) {
        return config;

    },function (error) {
        console.error('请求异常',error);
    });

    service.interceptors.response.use(function (response) {
        if(response.data.code==200){
           return response;
        }else{

        }
    },function (error) {
        return Promise.reject(error);
    });

    let fetch = service;
    window.fetch = fetch;
    if(Vue){
        Vue.prototype.fetch = fetch;
    }
})(window);
